import mx.managers.PopUpManager;

import net.optix.ip.model.ModelLocator;
import net.optix.ip.vo.InventionVO;

import views.invention.AddAction;

[Bindable]
private var model:ModelLocator	=	ModelLocator.getInstance();

public var _invention:InventionVO;

public function set invention(value:InventionVO):void
{
	_invention	=	value;
	var isVisible:Boolean	=	false;
	var status:int			=	value.status;
	
	if(model.role > 0 && model.role <3)
	{
		this.label	=	"Add New Action";
	}
	else
	{
		this.label	=	"Post Document/Record Action";
	}
	
	
	switch(model.role)
	{
		case 0:
			isVisible	=	false;
			break;
		case 1:
			if(model.client.clientID == value.clientID)
			{
				if(status < 6)
				{
					isVisible	=	true;
				}
			}
			break;
		case 2:
			if(model.inventor.inventorID == value.inventorID)
			{
				if(status < 6)
				{
					isVisible	=	true;
				}	
			}
			break;
		case 3:
			if(model.firm.firmID == value.firmID && value.bConfirm == 1)
			{
				if(status != 1 && status != 2 && status != 3)
				{
					isVisible	=	true;
				}
			}
			break;
		case 4:
			if(model.practitioner.practitionerID == value.practitionerID && value.bConfirm == 1)
			{
				if(status != 1 && status != 2 && status != 3)
				{
					isVisible	=	true;
				}
			}
			break;
		case 5:
			isVisible	=	false;
			break;
	}
	
	this.enabled	=	isVisible;
	
}
public function get invention():InventionVO
{
	return _invention;
}

private function addAction(event:MouseEvent):void
{			
	var win:AddAction	=	
		PopUpManager.createPopUp(this,AddAction,true) as AddAction;	
		PopUpManager.bringToFront(win);
}